#!/usr/bin/perl 
# findsuid.pl
use warnings;
use strict;

use File::Find;

my $count = 0;

sub is_suid {
   if (-x && (-u _ || -g _)) {
      $count++;
      print "\t'$File::Find::dir/$_' is ";
 
      if (-u _ && -g _) {
         print "setuid and setgid \n";
      } elsif (-u _) {
         print "setuid \n"
      } else {
         print "setgid \n"
      }
   }
}

print "Scanning for files in ", join(', ',@ARGV), ":\n";
find(\&is_suid, @ARGV);
print "$count setuid or setgid executables found \n";